package cn.slg.module.system.dal.dataobject.state;

import cn.slg.module.system.dal.dataobject.wujiang.WuJiangDO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.lang.reflect.Method;
import java.util.List;

@Data
@NoArgsConstructor
public abstract class State {
    // 是不是负面效果（增益效果还是负面效果）
    boolean isNegative;

    // 状态名
    String stateName;

    // 施加者
    WuJiangDO inflictor;

    // 接受者，
    WuJiangDO receiver;

    // 产生该状态的战法
    Method skill;

    // 产生该状态的战法名
    String skillName;

    // 状态效果剩余回合数 >0
    byte remainTimes;

    // 状态效果持续回合，状态被创建时赋值，用于刷新状态
    byte continueTimes;

    // 是否可以叠加
    boolean canAdd;

    // 是否可以刷新
    boolean canRefresh;

    public State(boolean isNegative, String stateName, WuJiangDO inflictor, WuJiangDO receivers, Method skill, String skillName, byte continueTimes) {
        this.isNegative = isNegative;
        this.stateName = stateName;
        this.inflictor = inflictor;
        this.receiver = receivers;
        this.skill = skill;
        this.skillName = skillName;
        this.continueTimes = continueTimes;
        this.remainTimes = continueTimes;
    }


    public abstract void end();

    // 状态，受属性影响战法效果
    public static Float isAffectedByPv(Float pv) {
        if (pv <= 100) {
            return pv / 100;
        } else {
            return (float) (1 + (pv - 100) * 0.00285);
        }
    }
}
